home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Texteditors / Origami / Sources / src / viewrc / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-27  |  31.9 KB  |  1,056 lines

  1. /*{{{}}}*/
  2. /*{{{  #includes*/
  3. #include <string.h>
  4. #include <stdlib.h>
  5. #include <sys/types.h>
  6. #ifndef NO_GETOPT_H
  7. #  include <getopt.h>
  8. #endif
  9. #include <stdio.h>
  10. #include <signal.h>
  11.  
  12. #define VIEW_MAIN_C
  13.  
  14. #include <h/os.h>
  15. #define I_SET_C
  16. #define BIND_CONST
  17. #include <h/keys.h>
  18.  
  19. #include "viewrc.h"
  20.  
  21. #define I_RC_CHECK
  22. #define CODE_LG_ARRAY
  23.  
  24. #include <h/rcformat.h>
  25. #include <h/envvar_str.h>
  26. #include <h/codelg.h>
  27. #include <h/getmsg.h>
  28. #include <lib/ori_rc_lib.h>
  29. /*}}}  */
  30.  
  31. /*{{{  variables*/
  32. FILE *rc;
  33. int info=0;
  34. char const ctrl_c[]=CTRL_CHARS;
  35. off_t vrc_off=0;
  36. boolean misc_out=False;
  37. boolean macro_out=False;
  38. boolean ktb_out=False;
  39. boolean ref_out=False;
  40. /*}}}  */
  41.  
  42. /*{{{  vrc_get_c*/
  43. #define vrc_get_c(f) (vrc_off+=rc_c_lg,rc_get_c(f))
  44. /*}}}  */
  45. /*{{{  vrc_get_w*/
  46. #define vrc_get_w(f) (vrc_off+=rc_w_lg,rc_get_w(f))
  47. /*}}}  */
  48. /*{{{  vrc_gets*/
  49. char *vrc_gets(char *buff,int lg,FILE *f)
  50. {
  51.   char *ret;
  52.  
  53.   ret=fgets(buff,lg,f);
  54.   vrc_off+=strlen(buff);
  55.  
  56.   return(ret);
  57. }
  58. /*}}}  */
  59. /*{{{  vrc_ftell*/
  60. #define vrc_ftell(f) (((f)==stdin)?vrc_off:ftell(f))
  61. /*}}}  */
  62. /*{{{  error_abort*/
  63. void error_abort(void)
  64. { fprintf(stderr,F_CRASH,vrc_ftell(rc));
  65.   exit(1);
  66. }
  67. /*}}}  */
  68. /*{{{  decode_mac*/
  69. /*{{{  get_dec*/
  70. char const *get_dec(TOKEN const x)
  71. {
  72.   if (x>=O_NOP && x<=O_EXE_MACRO)
  73.     return(dec[x-O_NOP]);
  74.   else if (x>O_EXE_MACRO)
  75.    { static char s[32];
  76.  
  77.      sprintf(s,"O_CALL_FIX %d",x-O_EXE_MACRO);
  78.      return(s);
  79.    }
  80.   else
  81.     return(M_UNKNOWN);
  82. }
  83. /*}}}  */
  84.  
  85. int decode_mac(FILE *f,int lg)
  86. {
  87.   int pc=0;
  88.   TOKEN x;
  89.   int dopc=1;
  90.  
  91.   while (lg) {
  92.     /*{{{  show each statement*/
  93.     x=vrc_get_w(f);
  94.     lg--;
  95.     if (x==EOF)
  96.       return(1);
  97.     else if (x<O_NOP) {
  98.       /*{{{  normal chars*/
  99.       if (dopc) {
  100.         /*{{{  with pc*/
  101.         if (macro_out)
  102.            if (x>=' ')
  103.              printf(F_NORM_PC,pc,(char) x);
  104.            else
  105.              printf(F_NORM,pc,x);
  106.         dopc=0;
  107.         /*}}}  */
  108.       } else {
  109.         /*{{{  without pc*/
  110.         if (macro_out)
  111.            if (x>=' ')
  112.              printf(F_CHAR,(char) x);
  113.            else
  114.              printf(F_DIGIT,x);
  115.         /*}}}  */
  116.       }
  117.       pc++;
  118.       /*}}}  */
  119.     } else {
  120.       /*{{{  opcodes*/
  121.       COM_TYPES t;
  122.  
  123.       /*{{{  maybe end string in last line*/
  124.       if (!dopc)
  125.        { if (macro_out)
  126.             printf(M_END_ST);
  127.          dopc=1;
  128.        }
  129.       /*}}}  */
  130.       /*{{{  get commandtyp*/
  131.       if (x<O_NOP || x>O_EXE_MACRO)
  132.          t=COM;
  133.       else
  134.          t=cmd_type[x-O_NOP];
  135.       /*}}}  */
  136.       switch (t) {
  137.         /*{{{  two int args*/
  138.         case COM_II: {
  139.           int x1=vrc_get_w(rc);
  140.           int x2=vrc_get_w(rc);
  141.  
  142.           lg-=2;
  143.           if (macro_out)
  144.              printf(F_OP_2_INT,pc,get_dec(x),x1,x2);
  145.           pc+=3;
  146.           break;
  147.         }
  148.         /*}}}  */
  149.         /*{{{  one int arg*/
  150.         case COM_I:
  151.          { int a1;
  152.          
  153.            lg--;
  154.            a1=vrc_get_w(rc);
  155.            if (macro_out)
  156.               printf(F_OP_1_INT,pc,get_dec(x),a1);
  157.            pc+=2;
  158.            break;
  159.          }
  160.         /*}}}  */
  161.         /*{{{  one char-argument*/
  162.         case COM_C: {
  163.           int x1=vrc_get_w(rc);
  164.  
  165.           lg--;
  166.           if (macro_out)
  167.              if (x1>=' ')
  168.                printf(F_OP_CHAR,pc,get_dec(x),x1,x1);
  169.              else
  170.                printf(F_OP_CODE,pc,get_dec(x),x1,ctrl_c[x1]);
  171.           pc+=2;
  172.           break;
  173.         }
  174.         /*}}}  */
  175.         /*{{{  0/1/2 int + prompt*/
  176.         case COM_IIP:
  177.         case COM_IP:
  178.         case COM_P: {
  179.           if (t==COM_IIP)
  180.            /*{{{  show cmd + 2 ints*/
  181.            { int x1,x2;
  182.  
  183.              x1=vrc_get_w(rc);
  184.              x2=vrc_get_w(rc);
  185.              lg-=2;
  186.              pc+=3;
  187.              if (macro_out)
  188.                 printf(F_OP_IIP,pc,get_dec(x),x1,x2);
  189.            }
  190.            /*}}}  */
  191.           else if (t==COM_IP)
  192.            /*{{{  show cmd + int*/
  193.            { int a1;
  194.  
  195.  
  196.              lg--;
  197.              a1=vrc_get_w(rc);
  198.              if (macro_out)
  199.                 printf(F_PROMPT_START,pc,get_dec(x),a1);
  200.              pc+=2;
  201.            }
  202.            /*}}}  */
  203.           else
  204.            /*{{{  show cmd*/
  205.            { if (macro_out)
  206.                 printf(F_EXIT_START,pc,get_dec(x));
  207.              pc++;
  208.            }
  209.            /*}}}  */
  210.           for (;;)
  211.            /*{{{  show one item of prompt, break on M_END_MACRO or macro/file end*/
  212.            { if (lg)
  213.               /*{{{  get token from macro*/
  214.               { lg--;
  215.                 x=vrc_get_w(rc);
  216.               }
  217.               /*}}}  */
  218.              else
  219.               /*{{{  break, M_END comes from auto-end!*/
  220.               { if (macro_out)
  221.                    printf(">\n");
  222.                 break;
  223.               }
  224.               /*}}}  */
  225.              if (x==M_END_MACRO)
  226.               /*{{{  show and break*/
  227.               { pc++;
  228.                 if (macro_out)
  229.                    printf(F_END_MACRO,get_dec(M_END_MACRO));
  230.                 break;
  231.               }
  232.               /*}}}  */
  233.              else if (x==EOF)
  234.               /*{{{  break, error*/
  235.                 break;
  236.               /*}}}  */
  237.              else if (x<O_NOP && x>=0)
  238.               /*{{{  show char*/
  239.               { if (macro_out)
  240.                    printf(F_CHAR,x);
  241.               }
  242.               /*}}}  */
  243.              else if (x<0)
  244.               /*{{{  show message*/
  245.               { ++x;
  246.                 if (macro_out)
  247.                    printf(F_MSG,-x+1,-x>=MSG_ARG_FORMAT?"":msg_list[-x]);
  248.               }
  249.               /*}}}  */
  250.              else if (x==M_INT_STRING)
  251.               /*{{{  counter*/
  252.               { int a1;
  253.  
  254.                 lg--;
  255.                 a1=vrc_get_w(rc);
  256.                 if (macro_out)
  257.                    printf(F_COUNTER,a1);
  258.                 pc++;
  259.               }
  260.               /*}}}  */
  261.              else
  262.               /*{{{  hope it was a history*/
  263.               { int a1;
  264.  
  265.                 lg--;
  266.                 a1=vrc_get_w(rc);
  267.                 if (macro_out)
  268.                    printf(F_HIST,a1);
  269.                 pc++;
  270.               }
  271.               /*}}}  */
  272.              pc++;
  273.            }
  274.            /*}}}  */
  275.           break;
  276.         }
  277.         /*}}}  */
  278.         /*{{{  adress*/
  279.         case COM_A: {
  280.           int ad=vrc_get_w(rc);
  281.  
  282.           if (macro_out)
  283.              printf(F_OP_ADRESS,pc,get_dec(x),ad,pc+2+ad);
  284.           lg--;
  285.           pc+=2;
  286.           break;
  287.         }
  288.         /*}}}  */
  289.         /*{{{  else only command*/
  290.         case COM:
  291.           if (macro_out)
  292.              if (x>O_EXE_MACRO)
  293.                 printf(F_OP_1_INT,pc,"O_CALL_FIX",x-O_EXE_MACRO);
  294.              else
  295.                 switch(x)
  296.                  { CASES_M_CALL
  297.                       printf(F_OP_ADRESS,pc,get_dec(x),x-M_CALL_0,pc+1+x-M_CALL_0);
  298.                       break;
  299.                    CASES_M_JMP
  300.                       printf(F_OP_ADRESS,pc,get_dec(x),x-M_JMP_0,pc+1+x-M_JMP_0);
  301.                       break;
  302.                    CASES_M_JMP_TRUE
  303.                       printf(F_OP_ADRESS,pc,get_dec(x),x-M_JMP_TRUE_0,pc+1+x-M_JMP_TRUE_0);
  304.                       break;
  305.                    CASES_M_JMP_FALSE
  306.                       printf(F_OP_ADRESS,pc,get_dec(x),x-M_JMP_FALSE_0,pc+1+x-M_JMP_FALSE_0);
  307.                       break;
  308.                    default:
  309.                       printf(F_OP,pc,get_dec(x));
  310.                       break;
  311.                  }
  312.           pc+=1;
  313.           break;
  314.         /*}}}  */
  315.       }
  316.       /*}}}  */
  317.     }
  318.     /*}}}  */
  319.   }
  320.   /*{{{  maybe end string in previous line*/
  321.   if (macro_out)
  322.      if (!dopc)
  323.         printf(M_END_ST);
  324.   /*}}}  */
  325.   /*{{{  automatic M_END_MACRO (generated in origami when reading rc)*/
  326.   if (macro_out)
  327.      printf(F_AUTO_END,pc,get_dec(M_END_MACRO));
  328.   /*}}}  */
  329.   return(0);
  330. }
  331. /*}}}  */
  332.  
  333. /*{{{  main*/
  334. int main(int argc, char *argv[])
  335. {
  336.   int mult=0;
  337.  
  338.   /*{{{  parse arguments*/
  339.   { int c;
  340.  
  341.     while ((c=getopt(argc,argv,"fikmr"))!=EOF)
  342.     switch (c)
  343.      {
  344.        /*{{{  f*/
  345.        case 'f': macro_out=True;break;
  346.        /*}}}  */
  347.        /*{{{  i*/
  348.        case 'i': info=1;break;
  349.        /*}}}  */
  350.        /*{{{  k*/
  351.        case 'k': ktb_out=True;break;
  352.        /*}}}  */
  353.        /*{{{  m*/
  354.        case 'm': misc_out=True;break;
  355.        /*}}}  */
  356.        /*{{{  r*/
  357.        case 'r': ref_out=True;break;
  358.        /*}}}  */
  359.        case 'h':
  360.        default:
  361.           printf(M_USAGE);
  362.           exit(0);
  363.      }
  364.     if (!ktb_out && !macro_out && !misc_out && !ref_out)
  365.        ktb_out=macro_out=misc_out=ref_out=True;
  366.   }
  367.   /*}}}  */
  368.   if (info)
  369.      show_help();
  370.   if (optind<(argc-1))
  371.      mult=1;
  372.   signal(SIGSEGV,(void(*)())error_abort);
  373.   do
  374.    /*{{{  handle one rc-file*/
  375.    { char const * rcfile;
  376.  
  377.      if (optind==argc)
  378.         rc=stdin;
  379.      else if (!(rc=fopen(rcfile=argv[optind++],(char*)"rb")))
  380.       { fprintf(stderr,F_NO_RC,rcfile);exit(1); }
  381.      if (mult)
  382.         printf("%s  %s\n",fo,rcfile);
  383.      /*{{{  scan rc-file*/
  384.      { int  input;
  385.        int macsize=0;
  386.        int mloadsize=0;
  387.        long int f_pos;
  388.        int bind_const[RCC_SIZE];
  389.  
  390.        ktb_count= -1;
  391.        f_pos=vrc_ftell(rc);
  392.        printf(F_CHECK,f_pos,vrc_get_w(rc),RC_CHECK);
  393.        f_pos=vrc_ftell(rc);
  394.        while (((input=vrc_get_c(rc))!=RC_ENDE)&&(input!=RC_BIND))
  395.         /*{{{  handle all rc-commands*/
  396.         { if (input==RC_DEFKEY && ktb_count>0)
  397.            /*{{{  keydef*/
  398.            { int nodes;
  399.  
  400.              /*{{{  decode and print table header with open fold*/
  401.              { char kname[NAME_LG+1];
  402.                char mark_str[1024];
  403.  
  404.                rc_get_s(rc,kname,NAME_LG);
  405.                nodes=vrc_get_w(rc);
  406.                /*{{{  read marks*/
  407.                { int i;
  408.  
  409.                  for (i=0,mark_str[0]='\0';i<ktb_count;i++)
  410.                   { char b[16];
  411.  
  412.                     sprintf(b," %d",rc_get_w(rc));
  413.                     if (strlen(mark_str)<1000)
  414.                        strcat(mark_str,b);
  415.                   }
  416.                }
  417.                /*}}}  */
  418.                if (ktb_out)
  419.                   printf
  420.                    ( F_KEY_HEAD,
  421.                      fo,
  422.                      f_pos,
  423.                      *kname?kname:"default",
  424.                      mark_str,
  425.                      nodes
  426.                    );
  427.              }
  428.              /*}}}  */
  429.              /*{{{  decode the tablenodes with close fold*/
  430.              { int no;
  431.  
  432.                for (no=0;nodes--;)
  433.                 { KEY k;
  434.                   int prt_key;
  435.                   char string[11];
  436.                   int co;
  437.                   int of1;
  438.                   int of2;
  439.  
  440.                   set_key_data(&k,rc);
  441.                   if (ktb_out)
  442.                    {
  443.                      /*{{{  set command value*/
  444.                      co=key_code(&k);
  445.                      if (key_far_next(&k))
  446.                         co=0;
  447.                      /*}}}  */
  448.                      /*{{{  get pointer id's*/
  449.                      if (key_next_ptr(&k))
  450.                         of1=no+(key_next_ptr(&k)-&k);
  451.                      else
  452.                         of1= -1;
  453.                      if (key_level_ptr(&k))
  454.                         of2=no+(key_level_ptr(&k)-&k);
  455.                      else
  456.                         of2= -1;
  457.                      /*}}}  */
  458.                      /*{{{  print values of the keytabnode*/
  459.                      prt_key=k.key;
  460.                      if (k.flags&MAGIC_KEY)
  461.                       { strcpy(string,"all");
  462.                         prt_key= -1;
  463.                       }
  464.                      else if (prt_key==127)
  465.                         strcpy(string,"DEL");
  466.                      else if (prt_key>(unsigned char)127)
  467.                         sprintf(string,"%.3X",prt_key);
  468.                      else if (prt_key<(unsigned char)' ')
  469.                       { string[0]='C';
  470.                         string[1]='-';
  471.                         string[2]=ctrl_c[prt_key];
  472.                         string[4]='\0';
  473.                       }
  474.                      else
  475.                         sprintf(string,"%c  ",prt_key);
  476.                      printf(F_NODE_VALUE,no,prt_key,string,of1,of2,co);
  477.                      no++;
  478.                      /*}}}  */
  479.                      /*{{{  maybe print coded command*/
  480.                      if (key_far_next(&k))
  481.                         printf(M_FAR_NEXT);
  482.                      else if (!co)
  483.                         printf(M_NEWLINE);
  484.                      else if (co==keytabknb)
  485.                         printf(F_KNB_NODE,co);
  486.                      else if (co==127)
  487.                         printf(M_DEL_NODE,co);
  488.                      else if (co>=O_NOP)
  489.                         printf(M_COM_NODE,co,get_dec(co));
  490.                      else if (co>=' ')
  491.                         printf(M_CODE_NODE,co,co);
  492.                      else
  493.                         printf(M_CTRL_NODE,co,ctrl_c[co]);
  494.                      /*}}}  */
  495.                    }
  496.                 }
  497.                if (ktb_out)
  498.                   printf(F_CLOSE,fc);
  499.              }
  500.              /*}}}  */
  501.            }
  502.            /*}}}  */
  503.           else
  504.            /*{{{  others*/
  505.            { switch (input) {
  506.                /*{{{  constants*/
  507.                case RC_CONST:
  508.                 { int i;
  509.  
  510.                   for (i=0;i<RCC_SIZE;i++)
  511.                      bind_const[i]=vrc_get_w(rc);
  512.                   if (misc_out)
  513.                    { printf(F_CONST,fo,f_pos);
  514.                      /*{{{  sizes*/
  515.                      printf(F_MACS,f_pos+i_m_count*rc_w_lg,mac_count);
  516.                      printf(F_INTS,f_pos+i_v_count*rc_w_lg,var_count);
  517.                      printf(F_KTBS,f_pos+i_k_count*rc_w_lg,ktb_count);
  518.                      /*}}}  */
  519.                      /*{{{  std vars*/
  520.                      printf(F_S1_VAR,fo,f_pos+i_v_cur_lev*rc_w_lg);
  521.                      printf
  522.                       ( F_S2_VAR,
  523.                         var_scr_w,
  524.                         var_off_w,
  525.                         var_scr_h,
  526.                         var_off_h,
  527.                         var_cur_lev,
  528.                         var_ocl_arg,
  529.                         var_file_no,
  530.                         var_us_buff,
  531.                         var_cu_buff,
  532.                         var_cu_b_id,
  533.                         var_m_edit,
  534.                         var_mod_beh,
  535.                         var_key_count,
  536.                         var_path,
  537.                         var_dired
  538.                       );
  539.                      printf(F_CLOSE,fc);
  540.                      /*}}}  */
  541.                      /*{{{  mouse vars*/
  542.                      printf(F_M_V1,fo,f_pos+i_v_m_x*rc_w_lg);
  543.                      printf
  544.                       ( F_M_V2,
  545.                         var_m_x,
  546.                         var_m_y,
  547.                         var_m_gy,
  548.                         var_m_out,
  549.                         var_m_but,
  550.                         var_m_buff
  551.                       );
  552.                      printf(F_CLOSE,fc);
  553.                      /*}}}  */
  554.                      /*{{{  switches*/
  555.                      if (var_notitle) printf(F_STAT,f_pos+i_v_notitle*rc_w_lg);
  556.                      if (arg_list) printf(F_F_LIST,f_pos+i_arg_list*rc_w_lg);
  557.                      /*}}}  */
  558.                      /*{{{  specials*/
  559.                      if (general_abort_key!=255)
  560.                       /*{{{  abort*/
  561.                         printf(F_BREAK,
  562.                                f_pos+i_general_abort_key*rc_w_lg,
  563.                                general_abort_key,
  564.                                (general_abort_key>=' ' ? "" : "C-"),
  565.                                (general_abort_key>=' ' ? general_abort_key : ctrl_c[general_abort_key]));
  566.                       /*}}}  */
  567.                      if (comma) printf(F_MODE_LIM,f_pos+i_comma*rc_w_lg,comma);
  568.                      if (eoln_str) printf(F_LINE_LIM,f_pos+i_lineend*rc_w_lg,eoln_str);
  569.                      if (soln_str) printf(F_SHIFT_MARK,f_pos+i_linestart*rc_w_lg,soln_str);
  570.                      /*}}}  */
  571.                      /*{{{  auto_macros*/
  572.                      if (auto_macro)
  573.                         printf(F_A_MACRO,f_pos+i_auto_macro*rc_w_lg,auto_macro);
  574.                      if (abort_macro)
  575.                         printf(F_AB_MACRO,f_pos+i_abort_macro*rc_w_lg,abort_macro);
  576.                      if (pin_macro)
  577.                         printf(F_PI_MACRO,f_pos+i_pin_macro*rc_w_lg,pin_macro);
  578.                      if (pout_macro)
  579.                         printf(F_PO_MACRO,f_pos+i_pout_macro*rc_w_lg,pout_macro);
  580.                      if (knb_macro)
  581.                         printf(F_K_MACRO,f_pos+i_knb_macro*rc_w_lg,knb_macro);
  582.                      if (view_macro)
  583.                         printf(F_V_MACRO,f_pos+i_view_macro*rc_w_lg,view_macro);
  584.                      if (buff_macro)
  585.                         printf(F_BCHG,f_pos+i_buff_macro*rc_w_lg,buff_macro);
  586.                      if (squit_macro)
  587.                         printf(F_SQM,f_pos+i_quit_macro*rc_w_lg,squit_macro);
  588.                      if (susr1_macro)
  589.                         printf(F_U1M,f_pos+i_usr1_macro*rc_w_lg,susr1_macro);
  590.                      if (susr2_macro)
  591.                         printf(F_U2M,f_pos+i_usr2_macro*rc_w_lg,susr2_macro);
  592.                      if (salarm_macro)
  593.                         printf(F_ALARM,f_pos+i_alarm_macro*rc_w_lg,salarm_macro);
  594.                      /*}}}  */
  595.                    }
  596.                   /*{{{  keyname*/
  597.                   { int i=BIND_NAME_LEN;
  598.                     char name[BIND_NAME_LEN+1];
  599.                     char *n=name;
  600.  
  601.                     while (i--) *n++=vrc_get_c(rc);
  602.                     *(n-1)='\0';
  603.                     if (misc_out)
  604.                        printf(F_NAME,f_pos+RCC_SIZE*rc_w_lg,name);
  605.                   }
  606.                   /*}}}  */
  607.                   /*{{{  ocl-opts*/
  608.                   { char opts[NO_OCL_CMD_OPTS*(2*BIND_NAME_LEN+2)];
  609.                     char *o;
  610.                     int o_no;
  611.                     off_t o_o_pos;
  612.  
  613.                     o_o_pos=f_pos+RCC_SIZE*rc_w_lg+BIND_NAME_LEN*rc_c_lg;
  614.                     /*{{{  read options field*/
  615.                     for (i=0;i<NO_OCL_CMD_OPTS*(2*BIND_NAME_LEN+2);i++)
  616.                        opts[i]=vrc_get_c(rc);
  617.                     /*}}}  */
  618.                     if (misc_out)
  619.                      {
  620.                        /*{{{  decode options*/
  621.                        for (o=opts,o_no=0;*o;)
  622.                         { do o++; while (*o);
  623.                           *o++='\t';
  624.                           while (*o) o++;
  625.                           *o++='\n';
  626.                           o_no++;
  627.                         }
  628.                        /*}}}  */
  629.                        if (o_no)
  630.                           printf(F_OCL_OPTS,fo,o_o_pos,o_no,opts,fc);
  631.                      }
  632.                   }
  633.                   /*}}}  */
  634.                   if (misc_out)
  635.                      printf("%s\n",fc);
  636.                   break;
  637.                 }
  638.                /*}}}  */
  639.                /*{{{  termalias*/
  640.                case RC_TERMALIAS:
  641.                 { char tname[NAME_LG+1];
  642.                   int ch;
  643.                   char *s;
  644.  
  645.                   if (ktb_out)
  646.                       printf(F_T_ALIAS,f_pos);
  647.                   while ((ch=vrc_get_c(rc)) && ch!=EOF)
  648.                    { s=tname;
  649.                      do *s++=(ch=vrc_get_c(rc)); while (ch && ch!=EOF);
  650.                      *s='\0';
  651.                      if (ktb_out)
  652.                         printf(F_T1_ALIAS,tname);
  653.                    }
  654.                   s=tname;
  655.                   do *s++=(ch=vrc_get_c(rc)); while (ch && ch!=EOF);
  656.                   if (ktb_out)
  657.                      printf(F_T2_ALIAS,tname);
  658.                   break;
  659.                 }
  660.                /*}}}  */
  661.                /*{{{  macroset*/
  662.                case RC_MAC_SET:
  663.                 { int lg;
  664.  
  665.                   lg=vrc_get_w(rc);
  666.                   if (macro_out)
  667.                      printf(F_MAC_SET,fo,f_pos,lg);
  668.                   do
  669.                    { int ml;
  670.                      int no;
  671.  
  672.                      f_pos=vrc_ftell(rc);
  673.                      no=vrc_get_w(rc);
  674.                      macsize+=(ml=vrc_get_w(rc))+1;
  675.                      if (macro_out)
  676.                         printf(F_MACRO_HEAD,fo,f_pos,no,ml+1,"def");
  677.                      if (!decode_mac(rc,ml))
  678.                       { if (macro_out)
  679.                            printf("%s\n",fc);
  680.                         lg-=ml+1;
  681.                       }
  682.                      else
  683.                         lg= -1;
  684.                    }
  685.                   while (lg>0);
  686.                   if (macro_out)
  687.                      if (!lg)
  688.                         printf("%s\n",fc);
  689.                   break;
  690.                 }
  691.                /*}}}  */
  692.                /*{{{  macroload/init*/
  693.                case RC_LOADMACRO:
  694.                case RC_INITMACRO:
  695.                 { int macro=vrc_get_w(rc);
  696.                   int lg=vrc_get_w(rc);
  697.  
  698.                   macsize+=lg+1;
  699.                   if (input==RC_LOADMACRO)
  700.                      mloadsize+=lg+1;
  701.                   if (macro_out)
  702.                      printf
  703.                       ( F_MACRO_HEAD,
  704.                         fo,
  705.                         f_pos,
  706.                         macro,
  707.                         lg+1,
  708.                         (input==RC_INITMACRO ? "init" : "load" )
  709.                       );
  710.                   if (!decode_mac(rc,lg))
  711.                      if (macro_out)
  712.                         printf("%s\n",fc);
  713.                   break;
  714.                 }
  715.                /*}}}  */
  716.                /*{{{  sets*/
  717.                case RC_CHARSET: {
  718.                  int no,word,off,po;
  719.                  char class[256];
  720.  
  721.                  no=vrc_get_w(rc);
  722.                  if (misc_out)
  723.                     printf(F_SET_HEAD,fo,f_pos,no);
  724.                  while (no)
  725.                   /*{{{  decode one class*/
  726.                   { for (word=0;word<SET_LG;word++)
  727.                      /*{{{  decode a byte*/
  728.                      { int byte=vrc_get_c(rc);
  729.  
  730.                        for (off=0;off<BITS_P_SET_PAKET;off++)
  731.                         { po=word*8+off;
  732.                           class[po]=(!(byte&(1<<off))?' ':((po>' ')?po:'X'));
  733.                         }
  734.                      }
  735.                      /*}}}  */
  736.                     no--;
  737.                     if (misc_out)
  738.                      { printf(F_SET_NO,no);
  739.                        printf(M_NEWLINE);
  740.                        /*{{{  print the title-index*/
  741.                        printf("    "HEX_CHARS HEX_CHARS HEX_CHARS HEX_CHARS " |");
  742.                        printf(M_NEWLINE);
  743.                        /*}}}  */
  744.                        for (word=0;word<16;word+=4)
  745.                         /*{{{  print line-index and following line-data*/
  746.                         { printf("%c-%c ",word+(word<10?'0':'A'-10),
  747.                                           word+(word<7 ?'3':'D'-10));
  748.                           for (off=0;off<64;off++)
  749.                             printf("%c",class[off+word*16]);
  750.                           printf(" |");
  751.                           printf(M_NEWLINE);
  752.                         }
  753.                         /*}}}  */
  754.                        printf(M_NEWLINE);
  755.                      }
  756.                   }
  757.                   /*}}}  */
  758.                  /*{{{  print set names*/
  759.                  if (misc_out)
  760.                     printf(F_SET_NAMES,vrc_ftell(rc));
  761.                  for (no=vrc_get_w(rc);no;no--)
  762.                   { char c;
  763.  
  764.                     c=vrc_get_c(rc);
  765.                     if (misc_out)
  766.                        putchar(c?c:'\n');
  767.                   }
  768.                  if (misc_out)
  769.                     putchar('\n');
  770.                  /*}}}  */
  771.                  if (misc_out)
  772.                     printf(F_CLOSE,fc);
  773.                  break;
  774.                }
  775.                /*}}}  */
  776.                /*{{{  usermodestrings*/
  777.                case RC_MODE: {
  778.                  int no;
  779.                  int lg;
  780.                  char *c;
  781.                  char buff1[BIND_NAME_LEN+1];
  782.                  char buff2[BIND_NAME_LEN+1];
  783.  
  784.  
  785.                  no=vrc_get_c(rc);
  786.                  /*{{{  get long*/
  787.                  lg=vrc_get_w(rc);
  788.                  c=buff1;
  789.                  while (lg--) *c++=vrc_get_c(rc);
  790.                  *c='\0';
  791.                  /*}}}  */
  792.                  /*{{{  get short*/
  793.                  lg=vrc_get_w(rc);
  794.                  c=buff2;
  795.                  while (lg--) *c++=vrc_get_c(rc);
  796.                  *c='\0';
  797.                  /*}}}  */
  798.                  if (misc_out)
  799.                     printf(F_U_MODE,f_pos,no,buff1,buff2[0]?buff2:buff1);
  800.                  break;
  801.                }
  802.                /*}}}  */
  803.                /*{{{  os-extension*/
  804.                case RC_COMMENT:
  805.                case RC_OS_EXTENSION:
  806.                  if (misc_out)
  807.                     printf(input==RC_COMMENT?F_COMMENT:F_OS_EXT,f_pos);
  808.                  while ((input=vrc_get_c(rc)) && input!=EOF)
  809.                     if (misc_out)
  810.                        printf("%c",input);
  811.                  if (misc_out)
  812.                     printf(">\n");
  813.                  break;
  814.                /*}}}  */
  815.                /*{{{  marks*/
  816.                case RC_MARKS: {
  817.                  char name[FOLD_PATTERN_LEN];
  818.                  int i;
  819.  
  820.                  /*{{{  read stored name*/
  821.                  for (i=0;i<(FOLD_PATTERN_LEN-1);i++)
  822.                    name[i]=vrc_get_c(rc);
  823.                  name[FOLD_PATTERN_LEN-1]='\0';
  824.                  /*}}}  */
  825.                  if (misc_out)
  826.                     printf(F_MARK,f_pos,name);
  827.                  /*{{{  mark*/
  828.                  if (misc_out)
  829.                     putchar('\'');
  830.                  for (i=0;i<FOLD_TAG_LENGTH;i++)
  831.                   { char c;
  832.  
  833.                     c=vrc_get_c(rc);
  834.                     if (misc_out)
  835.                        c=putchar(c);
  836.                   }
  837.                  if (misc_out)
  838.                     putchar('\'');
  839.                  if (misc_out)
  840.                     putchar(' ');
  841.                  /*}}}  */
  842.                  /*{{{  mark*/
  843.                  if (misc_out)
  844.                     putchar('\'');
  845.                  for (i=0;i<FOLD_TAG_LENGTH;i++)
  846.                   { char c;
  847.  
  848.                     c=vrc_get_c(rc);
  849.                     if (misc_out)
  850.                        c=putchar(c);
  851.                   }
  852.                  if (misc_out)
  853.                     putchar('\'');
  854.                  if (misc_out)
  855.                     putchar(' ');
  856.                  /*}}}  */
  857.                  /*{{{  mark*/
  858.                  if (misc_out)
  859.                     putchar('\'');
  860.                  for (i=0;i<FOLD_TAG_LENGTH;i++)
  861.                   { char c;
  862.  
  863.                     c=vrc_get_c(rc);
  864.                     if (misc_out)
  865.                        c=putchar(c);
  866.                   }
  867.                  if (misc_out)
  868.                     putchar('\'');
  869.                  if (misc_out)
  870.                     putchar(' ');
  871.                  /*}}}  */
  872.                  /*{{{  mark*/
  873.                  if (misc_out)
  874.                     putchar('\'');
  875.                  for (i=0;i<FOLD_TAG_LENGTH;i++)
  876.                   { char c;
  877.  
  878.                     c=vrc_get_c(rc);
  879.                     if (misc_out)
  880.                        c=putchar(c);
  881.                   }
  882.                  if (misc_out)
  883.                     putchar('\'');
  884.                  /*}}}  */
  885.                  if (misc_out)
  886.                     printf(M_NEWLINE);
  887.                  break;
  888.                }
  889.                /*}}}  */
  890.                /*{{{  mouse-mapping*/
  891.                case RC_M_TAB: {
  892.                  int i,j,map;
  893.  
  894.                  if (ktb_out)
  895.                     printf(F_MO_MAP1,fo,f_pos);
  896.                  for (j=0,i=vrc_get_w(rc);i--;j++) {
  897.                    map=vrc_get_w(rc);
  898.                    if (ktb_out)
  899.                     /*{{{  print it*/
  900.                       if (map==127)
  901.                         printf(F_MO_DEL,j);
  902.                       else if (map>=O_NOP)
  903.                         printf(F_MO_OP,j,map,get_dec(map));
  904.                       else if (map>=' ')
  905.                         printf(F_MO_CHAR,j,map,map);
  906.                       else
  907.                         printf(F_MO_CTRL,j,map,ctrl_c[map]);
  908.                     /*}}}  */
  909.                  }
  910.                  if (ktb_out)
  911.                     printf(F_CLOSE,fc);
  912.                  break;
  913.                }
  914.                /*}}}  */
  915.                /*{{{  strings*/
  916.                case RC_STRINGS:
  917.                 { int no;
  918.                   int ad;
  919.  
  920.                   ad=vrc_get_w(rc);
  921.                   no=vrc_get_w(rc);
  922.                   if (misc_out)
  923.                      printf(F_STR,fo,f_pos,ad,no);
  924.                   ad+=MSG_ARG_FORMAT;
  925.                   while (no--)
  926.                    { char c;
  927.  
  928.                      c=vrc_get_c(rc);
  929.                      if (misc_out)
  930.                         if (c)
  931.                            putchar(c);
  932.                         else
  933.                            printf("=%d\n",ad--);
  934.                    }
  935.                   if (misc_out)
  936.                      printf(F_CLOSE,fc);
  937.                   break;
  938.                 }
  939.                /*}}}  */
  940.                /*{{{  compress word list for ref*/
  941.                case RC_REF_COMP_STR:
  942.                 { char *code;
  943.  
  944.                   code=ref_read_comp_data(rc);
  945.                   if (misc_out)
  946.                      printf(F_COMP_DATA,fo,f_pos);
  947.                   if (code)
  948.                      while (*code)
  949.                       { do
  950.                            if (misc_out)
  951.                               putchar(*code);
  952.                         while (*++code);
  953.                         if (misc_out)
  954.                            putchar('\n');
  955.                         code++;
  956.                       }
  957.                   if (misc_out)
  958.                      printf(F_CLOSE,fc);
  959.                   break;
  960.                 }
  961.                /*}}}  */
  962.                /*{{{  error!*/
  963.                default:
  964.                   printf(F_ERROR,f_pos,input);
  965.                   fprintf(stderr,M_BAD_DATA);
  966.                   exit (1);
  967.                /*}}}  */
  968.              }
  969.            }
  970.            /*}}}  */
  971.           f_pos=vrc_ftell(rc);
  972.         }
  973.         /*}}}  */
  974.        if (input==RC_BIND)
  975.         /*{{{  show the help*/
  976.         { char line[RC_HELP_LEN+1];
  977.  
  978.           if (ref_out)
  979.              printf(F_HELPHEAD,fo,f_pos);
  980.           while (f_pos=vrc_ftell(rc),vrc_gets(line,RC_HELP_LEN,rc))
  981.               if (ref_out)
  982.                {
  983.                  /*{{{  cut newline*/
  984.                  { char *t;
  985.  
  986.                    for (t=line;*t && *t!='\n';t++);
  987.                    *t='\0';
  988.                  }
  989.                  /*}}}  */
  990.                  /*{{{  print line*/
  991.                  { char *t;
  992.  
  993.                    for (t=line;;)
  994.                     { switch (*t++)
  995.                        { case REF_NODE_LIMITER:
  996.                           /*{{{  print decoded line*/
  997.                           { char long_line[RC_HELP_LEN+1];
  998.  
  999.                             *(t-1)='\0';
  1000.                             printf
  1001.                              ( F_H_LINE1,
  1002.                                f_pos,
  1003.                                ref_decode_tag((unsigned char*)line),
  1004.                                t
  1005.                              );
  1006.                             fflush(stdout);
  1007.                             ref_uncompress_text(t,long_line);
  1008.                             printf
  1009.                              ( F_H_LINE2,
  1010.                                strlen(long_line)-strlen(t),
  1011.                                long_line
  1012.                              );
  1013.                             break;
  1014.                           }
  1015.                           /*}}}  */
  1016.                          case REF_NODE_ALIAS:
  1017.                           /*{{{  print decoded alias*/
  1018.                           { *(t-1)='\0';
  1019.                             printf
  1020.                              ( F_H_ALIAS,
  1021.                                f_pos,
  1022.                                ref_decode_tag((unsigned char*)line),
  1023.                                ref_decode_tag((unsigned char*)t)
  1024.                              );
  1025.                             break;
  1026.                           }
  1027.                           /*}}}  */
  1028.                          case '\0':
  1029.                             break;
  1030.                          default:
  1031.                             continue;
  1032.                        }
  1033.                       break;
  1034.                     }
  1035.                  }
  1036.                  /*}}}  */
  1037.                }
  1038.           if (ref_out)
  1039.              printf(F_CLOSE,fc);
  1040.         }
  1041.         /*}}}  */
  1042.        printf(F_ENDE,f_pos);
  1043.        if (macro_out)
  1044.           printf(F_MACSIZE,macsize,macsize-mloadsize,mloadsize);
  1045.      }
  1046.      /*}}}  */
  1047.      fclose(rc);
  1048.      if (mult)
  1049.         printf(F_CLOSE,fc);
  1050.    }
  1051.    /*}}}  */
  1052.   while (optind!=argc);
  1053.   exit(0);
  1054. }
  1055. /*}}}  */
  1056.